{layout name="layout" /}
<div class="tipbox tipbox-message m10">
    选择父权限后,无需再选择子权限。
</div>
<form id="form" action="{:url('admin/group/add')}">
<table class="formtable">
<tr>
    <th>组名称:</th>
    <td><input datatype="*" class="input w300" type="text" name="title" value=""/></td>
</tr>
<tr>
    <th>权限节点:</th>
    <td class="ztree"><ul id="GroupTree"></ul></td>
</tr>
<tr>
    <th>节点ID:</th>
    <td>
        <input datatype="*" class="input w300 readonly" type="text" name="auth_ids" id="auth_ids" value="" readonly/>
    </td>
</tr>
<tr>
    <th>备注:</th>
    <td><textarea datatype="*" name="about" class="textarea" style="width:300px;height:80px"></textarea></td>
</tr>
<tr>
    <th></th>
    <td>
        <input type="submit" value="{$Think.lang.lang_ui_save}" class="button button-blue submit" />
        <input type="reset" value="{$Think.lang.lang_ui_reset}" class="button button-blank"/>
    </td>
</tr>
</table>
</form>
<script type="text/javascript">
Do('base','layer','form','zTree',function(){
    $('#form').isForm();
    //权限目录
    var setting = {
        check: {enable: true,chkStyle: "checkbox",chkboxType:{"Y":'',"N":'s'}},
        data: {simpleData: {enable: true}},
        callback: {onCheck: onCheck,onClick:onClick},
        view: {dblClickExpand: false},
    };
    var group_list = "{:url('admin/auth/ids')}";
    $.getJSON(group_list,function(data){
        var zNodes = data;
        $.fn.zTree.init($("#GroupTree"),setting,zNodes);
    });
})  
//选择判断
function onCheck(e, treeId, treeNode) {
    var zTree = $.fn.zTree.getZTreeObj("GroupTree");
    nodes = zTree.getCheckedNodes(true),
    v = "";
    for (var i = 0, l = nodes.length; i<l; i++) {
        v += nodes[i].id + ",";
    }
    if (v.length > 0 ){
        v = v.substring(0, v.length-1);
    } 
    $("#auth_ids").attr("value", v);
};
//展开关闭
function onClick(e,treeId, treeNode) {
    var zTree = $.fn.zTree.getZTreeObj("GroupTree");
    zTree.expandNode(treeNode);
}
</script>